const fs = require("fs");
const path = require('path')
// 修改前的内容
let updateStr = "【 微信号：itcodeba 】【海量资源：nobug1024.com】";
// 要替换的内容
let newStr = "";

function readDir(url) {
  const files = fs.readdirSync(url);
  files.forEach((file, index) => {
    if (file.includes(updateStr)) {
      let newName = file.replace(updateStr, newStr);
      console.log(url+files[index], newName)
      fs.rename(`${url + '/' + files[index]}`, `${url + '/' + newName}`, (err) => {
        if (!err) {
          console.log(newName + " 已重命名！");
        }
      });
    }
    const location = path.join(url, file);

    const info = fs.statSync(location);
    if(info.isDirectory()){
      readDir(location);
    }
  });
  
}

readDir(process.cwd())